/**
 * class: NodeRecord
 * 		- Defines the tuple structure for the routing table
 * 			- A Middleware instance instantiates and keeps record on it.
 * 			- Node instances repeatedly refer the routing table to find the target id. 
 */
package common;

public class NodeRecord{
	int pid;
	long ip;
	
	public NodeRecord( int new_pid, long new_ip ){
		pid = new_pid;
		ip = new_ip;
	}
	
	// for Hashtable (it needs comparator hashcode generator)
	@Override
	public boolean equals( Object that ){
		if( this == that ) return true;
		if ( !( that instanceof NodeRecord ) ) return false;
		NodeRecord c_that = ( NodeRecord )that;
		  
		return pid == c_that.pid && ip == c_that.ip;
	}
	
	// for Hashtable (it needs comparator and hashcode generator)
	@Override
	public int hashCode(){
		int hash = pid % 13;
		hash *= 7;
		hash += ( ip % 17 );
		hash *= 11;
		
		return hash;
	}
	
	public String toString()
	{
		return pid+","+ip;
	}
}
